package huawei.window;

/**
 * https://leetcode-cn.com/problems/substrings-of-size-three-with-distinct-characters/
 */
public class J1876 {
    public static void main(String[] args) {

    }
    public int countGoodSubstrings(String s) {
        int[] cache = new int[26];
        int res =0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            cache[c-'a']++;
            if(i+1>=3){
                // 判断好字串
                boolean isGood=true;
                for(int count:cache){
                    if(count>1){
                        isGood=false;
                        break;
                    }
                }
                if(isGood){
                    res++;
                }
                cache[s.charAt(i+1-3)-'a']--;
            }
        }
        return res;
    }
}
